﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace myFinance.Controls
{
    public partial class AddExpence : UserControl, myFinance.Entity.IExpence
    {
        public AddExpence()
        {
            InitializeComponent();
            this.txtDescription.Focus();

            this.cbCategory.DataSource = 
                DAL.DALFactory.GetDAL<DAL.SqlCeDAL>().GetAllCategoriesIdAndNames();
            this.cbCategory.ValueMember = "Key";
            this.cbCategory.DisplayMember = "Value";

            this.cbLocation.DataSource =
                DAL.DALFactory.GetDAL<DAL.SqlCeDAL>().GetAllLocationsIdAndNames();
            this.cbLocation.ValueMember = "Key";
            this.cbLocation.DisplayMember = "Value";
        }

        public int CategoryID
        {
            set
            {
                cbCategory.SelectedValue = value;
            }
            get
            {
                return Convert.ToInt32(cbCategory.SelectedValue);
            }
        }

        public int LocationID
        {
            set
            {
                cbLocation.SelectedValue = value;
            }
            get
            {
                return Convert.ToInt32(cbLocation.SelectedValue);
            }
        }
        
        public double Amount
        {
            set
            {
                txtAmount.Text = value.ToString();
            }
            get
            {                
                return Convert.ToDouble(txtAmount.Text);
            }
        }

        public DateTime Date
        {
            get
            {
                return dtpDate.Value;
            }
            set
            {
                dtpDate.Value = value;
            }
        }

        public string Description
        {
            get
            {
                return txtDescription.Text;
            }
            set
            {
                txtDescription.Text = value;
            }
        }

        public new myFinance.Entity.ILocation Location
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public myFinance.Entity.ICategory Category
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}
